package com.stockz.ui.swing.charting.display.indicator;

import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.indicator.ord.OrdIndicator;
import com.stockz.indicator.ord.OrdSwing;
import com.stockz.ui.swing.charting.painter.indicator.OrdIndicatorPainter;
import com.stockz.ui.swing.charting.util.UIChartingConstant.OVERLAY;

@Component
@Scope("prototype")
public class Ord extends AbstractDisplayableIndicatorConfiguration {

	private OrdIndicator ordIndicator = new OrdIndicator();
	private final String fullName = "Ord Indicator";
	private final String shortName = "ORD";
	private final List<OrdSwing> ordSwingList = new ArrayList<OrdSwing>();
	
	@Override
	public void paint(Graphics2D g) {
		OrdIndicatorPainter.paint(g, this);
	}
	
	@Override
	public BarValueType getBarValueType() {
		return ordIndicator.getBarValueType();
	}
	
	@Override
	public void setBarValueType(BarValueType barValueType) {
		ordIndicator.setBarValueType(barValueType);
	}

	
	@Override
	public Object getConfiguration() {
		return ordIndicator.getIndicatorConfiguration();
	}
	
	@Override
	public OVERLAY getOverlay() {
		return OVERLAY.PRICE;
	}
	
	@Override
	public String getFullName() {
		return fullName;
	}

	@Override
	public String getShortName() {
		return shortName;
	}
	
	@Override
	public void refreshValues() {
		ordSwingList.clear();
		ordSwingList.addAll(ordIndicator.getOrdSwingList(getStockChartPanel().getStockChartPanelState().getBarList()));
	}

	@Override
	public String getDescription() {
		return shortName+","+ordIndicator.getIndicatorConfiguration().getPercentage();
	}

	@Override
	public boolean isOverlappable() {
		return false;
	}

	public List<OrdSwing> getOrdSwingList() {
		return ordSwingList;
	}

}
